﻿// ***********************************************************************
// Assembly         : MVC4Portal
// Author           : Lolo
// Created          : 09-23-2013
//
// Last Modified By : Lolo
// Last Modified On : 10-27-2013
// ***********************************************************************
// <copyright file="LocalizedURLHandler.cs" company="">
//     Copyright (c) . All rights reserved.
// </copyright>
// <summary></summary>
// ***********************************************************************
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace InnovaApp.Portals.MVC4Portal.Controllers.FriendlyURLHandling
{
    /// <summary>
    /// Class LocalizedURLHandler.
    /// </summary>
    public class LocalizedURLHandler : System.Web.Mvc.MvcRouteHandler
    {
        /// <summary>
        /// Returns the HTTP handler by using the specified HTTP context.
        /// </summary>
        /// <param name="requestContext">The request context.</param>
        /// <returns>The HTTP handler.</returns>
        protected override IHttpHandler GetHttpHandler(System.Web.Routing.RequestContext requestContext)
        {
            string language = PortalEnvironment.DefaultLanguage;
            if (requestContext.RouteData.Values["language"] != null)
            {
                language = requestContext.RouteData.Values["language"].ToString();
            }
            INNOVACALL.Framework.Common.MVCHelpers.Localization.CommonLocalization.SetCurrentThreadLanguage(language);
            return base.GetHttpHandler(requestContext);
        }
    }
}